/*
* 用户
* */
//引入mongoose
const mongoose = require('mongoose');
//创建用户集合
const userSchema = new mongoose.Schema({
  username: {
    type: String,
    //唯一，保证不重复
    unique: true,
    required: true,
    minlength: 2,
    maxlength: 15
  },
  email: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true
  },
  role: {
    type: String,
    required: true,
    default: '用户'
  },
  state: {
    type: Number,
    //0:禁用状态
    //1：启用状态
    default: 1
  },
  introduce: {
    type: String,
    default: null
  },
  profilePhoto: {
    type: String,
    default: null
  }
});

//创建集合
const User = mongoose.model('User',userSchema);
/*
User.create({
  username: 'xiaowang',
  email: 'xiaowang@163.com',
  password: 'xiaowang',
  role: '用户',
  state: 1,
  introduce: '我是用户，嘿嘿嘿！！！',
  profilePhoto: "\\uploads\\xiaowang.jpeg"
}).then(()=>{
  console.log('用户创建成功！');
}).catch(()=>{
  console.log('用户创建失败！');
})*/
//导出集合User
module.exports = {
  User
};